package org.mat.ipaas.ucenter.service.api.system;

import org.mat.framework.lang.dto.MatApiResponse;
import org.mat.ipaas.ucenter.service.dto.system.entity.SysCheckRuleDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;

/**
 * 编码校验规则
 */
@FeignClient(name = "mat-ipaas-ucenter-service", contextId = "sys-check-rule-rest-api")
public interface SysCheckRuleRestAPI {

    /**
     * 分页列表查询
     *
     * @param sysCheckRuleDTO
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/sys/checkRule/list")
    MatApiResponse queryPageList(
            @SpringQueryMap SysCheckRuleDTO sysCheckRuleDTO,
            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize
    );


    /**
     * 通过id查询
     *
     * @param ruleCode
     * @return
     */
    @GetMapping(value = "/sys/checkRule/checkByCode")
    MatApiResponse checkByCode(
            @RequestParam(name = "ruleCode") String ruleCode,
            @RequestParam(name = "value") String value
    ) throws UnsupportedEncodingException;

    /**
     * 添加
     *
     * @param sysCheckRuleDTO
     * @return
     */
    @PostMapping(value = "/sys/checkRule/add")
    MatApiResponse add(@RequestBody SysCheckRuleDTO sysCheckRuleDTO);

    /**
     * 编辑
     *
     * @param sysCheckRuleDTO
     * @return
     */
    @RequestMapping(value = "/sys/checkRule/edit", method = {RequestMethod.POST})
    MatApiResponse edit(@RequestBody SysCheckRuleDTO sysCheckRuleDTO);

    /**
     * 通过id删除
     *
     * @param id
     * @return
     */
    @DeleteMapping(value = "/sys/checkRule/delete")
    MatApiResponse delete(@RequestParam(name = "id", required = true) String id);

    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @DeleteMapping(value = "/sys/checkRule/deleteBatch")
    MatApiResponse deleteBatch(@RequestParam(name = "ids", required = true) String ids);

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/sys/checkRule/queryById")
    MatApiResponse queryById(@RequestParam(name = "id", required = true) String id);

    /**
     * 导出excel
     *
     * @param sysCheckRuleDTO
     */
    @RequestMapping(value = "/sys/checkRule/exportXls")
    ModelAndView exportXls(SysCheckRuleDTO sysCheckRuleDTO);

    /**
     * 通过excel导入数据
     *
     * @return
     */
    @RequestMapping(value = "/sys/checkRule/importExcel", method = RequestMethod.POST)
    MatApiResponse importExcel();
}
